package com.mvc.web.task;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class Task{
	
	
	
	
	private static int a = 0;

	public void run() {
		
	}
	
	@Scheduled(fixedRate=1000*60*5)
	public void testTask(){
		ExecutorService exe = Executors.newFixedThreadPool(10);
		for (int i = 0; i < 10; i++) {
			final int a = i; 
			exe.execute(new Runnable() {
				
				public void run() {
					System.out.println("123123  a=="+a);
					System.out.println(getCount());
				}
			});
		}
		exe.shutdown();
		try {
			exe.awaitTermination(Long.MAX_VALUE, TimeUnit.HOURS);
			System.out.println("all thread complete");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static int getCount(){
		return a++;
	}
	
	
	
}
